FROM php:7.0.13-fpm as php-fpm
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak \
    && echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list \
    && echo "deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >>/etc/apt/sources.list \
    && echo "#deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >>/etc/apt/sources.list \
    && echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list \
    && echo "deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib" >>/etc/apt/sources.list \
    && echo "#deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib" >>/etc/apt/sources.list \
    && echo "deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" >>/etc/apt/sources.list \
    && echo "deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib" >>/etc/apt/sources.list
# 安装扩展
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        libmemcached-dev \
        zlib1g-dev \
        libcurl4-openssl-dev \
        libxml2-dev \
        --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN docker-php-source extract
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include
RUN docker-php-ext-install -j$(nproc) \
        iconv mcrypt gettext curl mysqli pdo pdo_mysql zip \
        mbstring bcmath opcache xml simplexml sockets hash soap xmlwriter gd
# 安装imap扩展
RUN apt-get update && apt-get install -y --no-install-recommends libc-client-dev libkrb5-dev \
        && rm -r /var/lib/apt/lists/* \
        && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
        && docker-php-ext-install -j$(nproc) imap
# 安装自定义插件 pecl: https://pecl.php.net/package-search.php
RUN pecl install \
    && pecl install xdebug-2.8.1 \
    && pecl install redis-3.1.6 \
    && pecl install xhprof-2.2.2 \
    && pecl install xlswriter-1.3.6 \
    && pecl install swoole-4.3.6 \
    && docker-php-ext-enable redis xhprof xlswriter swoole
#    xdebug
# 安装易用扩展
RUN apt-get update \
    && apt-get install -y vim sudo less git zip unzip lrzsz net-tools wget graphviz iputils-ping
#安装 PHP composer
#RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \
#    && php composer-setup.php --version=1.9.3 \
#    && php -r "unlink('composer-setup.php');" \
#    && sudo mv composer.phar /usr/local/bin/composer \
#    && composer config -g repo.packagist composer https://packagist.phpcomposer.com
# 旧版本composer
COPY ./composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# 自定义服务
RUN echo "export LS_OPTIONS='--color=auto'" >>~/.bashrc
RUN echo "eval "`dircolors`"" >>~/.bashrc
RUN echo "alias ll='ls \$LS_OPTIONS -l'" >>~/.bashrc
RUN ln -sfn /var/www /root/www \
    && ln -sfn /var/log /root/log

#CMD service ssh start && tail -F /var/log/mysql/error.log
#COPY start.sh /usr/local/bin/start.sh
#RUN chmod 777 /usr/local/bin/start.sh
# 导致关闭速度缓慢
#CMD /usr/local/bin/start.sh;sleep infinity
#RUN git config --global user.name "蒋尚君" \
#    && git config --global user.email "jiangshangjun@asinking.com"
